package cac.fenjian.resource.mssslshelves.api;

import cac.fenjian.resource.MsSslShelves.dto.MsSslShelvesDTO;
import com.cac.dme.adapter.rest.client.RestClient;
import com.cac.dme.adapter.rest.msg.QueryReqBean;
import com.cac.dme.adapter.rest.msg.ResponseMsg;
import com.cac.dme.adapter.utils.RestClientUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program test-curd
 * @description 立体库货位信息表API接口
 * @author: LSL
 * @create: 2022-07-14-15-23
 **/
@RestController
@RequestMapping("/MsSslShelvesApi")
public class MsSslShelvesApi {

    /**
     * 服务编码
     */
    private static final String SERVICE_CODE="xdCommonData";
    private static final String BASE_PATH = "/MsSslShelves";

    @Autowired
    private RestClient restClient;

    /**
     * 新增立体库位信息表数据API
     * @param msSslShelvesDTO
     * @return
     */
    @PostMapping("/insertData")
    public String insertData(@RequestBody MsSslShelvesDTO msSslShelvesDTO){
        String url = BASE_PATH +"/save/v1";
        ResponseMsg<String> responseMsg = restClient.doPost(SERVICE_CODE, url, msSslShelvesDTO, new ParameterizedTypeReference<ResponseMsg<String>>() {
        });
        return RestClientUtils.getResponseBody(responseMsg);
    }

    /**
     * 批量新增立体库信息表数据
     * @param msSslShelvesDTOS
     * @return
     */
    @PostMapping("/insertDataMany")
    public String insertDataMany(@RequestBody List<MsSslShelvesDTO> msSslShelvesDTOS){
        String url = BASE_PATH +"/batchSave/v1";
        ResponseMsg<String> responseMsg = restClient.doPost(SERVICE_CODE, url, msSslShelvesDTOS, new ParameterizedTypeReference<ResponseMsg<String>>() {
        });
        return RestClientUtils.getResponseBody(responseMsg);
    }

    /**
     * 修改数据
     * @param msSslShelvesDTO
     * @return
     */
    @PostMapping("/updateData")
    public Integer updateData(@RequestBody MsSslShelvesDTO msSslShelvesDTO){
        String url = BASE_PATH +"/update/v1";
        ResponseMsg<Integer> responseMsg = restClient.doPost(SERVICE_CODE, url, msSslShelvesDTO, new ParameterizedTypeReference<ResponseMsg<Integer>>() {
        });
        return RestClientUtils.getResponseBody(responseMsg);
    }

    /**
     * 批量修改数据
     * @param msSslShelvesDTOS
     * @return
     */
    @PostMapping("/updateDataMany")
    public Integer updateDataMany(@RequestBody List<MsSslShelvesDTO> msSslShelvesDTOS){
        String url = BASE_PATH +"/updateMany/v1";
        ResponseMsg<Integer> responseMsg = restClient.doPost(SERVICE_CODE, url, msSslShelvesDTOS, new ParameterizedTypeReference<ResponseMsg<Integer>>() {
        });
        return  RestClientUtils.getResponseBody(responseMsg);
    }

    /**
     * 根据条件查询数据
     * @param queryReqBean
     * @return
     */
    @PostMapping("/searchByParams")
    public List<MsSslShelvesDTO> searchByParams(@RequestBody QueryReqBean<MsSslShelvesDTO> queryReqBean){
        String url = BASE_PATH +"/searchByParams/v1";
        ResponseMsg<List<MsSslShelvesDTO>> responseMsg = restClient.doPost(SERVICE_CODE, url, queryReqBean, new ParameterizedTypeReference<ResponseMsg<List<MsSslShelvesDTO>>>() {
        });
        return RestClientUtils.getResponseBody(responseMsg);
    }


}
